package com.whnk.attendance.controller;

import com.whnk.attendance.service.IPmSignInfoService;
import com.whnk.attendance.vo.DailySignListVo;
import com.whnk.attendance.vo.DailySignQueryVo;
import com.whnk.common.core.utils.poi.ExcelUtil;
import com.whnk.common.core.web.controller.BaseController;
import com.whnk.common.core.web.page.TableDataInfo;
import com.whnk.common.log.annotation.Log;
import com.whnk.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 日常考勤报表
 *
 * @author whnk
 * @date 2021-11-17
 */
@Api(tags = "日常考勤报表")
@RestController
@RequestMapping("/DailySignInfo")
public class DailySignController extends BaseController {

    @Autowired
    private IPmSignInfoService pmSignInfoService;
    /**
     * 查询日常考勤报表
     */
    @ApiOperation(value = "查询日常考勤报表")
    // @PreAuthorize(hasPermi = "attendance:statis:list")
    @GetMapping("/list")
    public TableDataInfo list(DailySignQueryVo dailySignQueryVo)
    {
        startPage();
        List<DailySignListVo> list = pmSignInfoService.queryDailySignReport(dailySignQueryVo);
        return getDataTable(list);
    }

    /**
     * 导出日常考勤报表
     */
    @ApiOperation(value = "导出日常考勤报表")
    // @PreAuthorize(hasPermi = "attendance:statis:export")
    @Log(title = "导出日常考勤报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailySignQueryVo dailySignQueryVo) throws IOException
    {
        List<DailySignListVo> list = pmSignInfoService.queryDailySignReport(dailySignQueryVo);
        ExcelUtil<DailySignListVo> util = new ExcelUtil<DailySignListVo>(DailySignListVo.class);
        util.exportExcel(response, list, "日常考勤报表");
    }


}
